<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php $this->load->view('head'); ?>
	<script>
	var site_url = "http://localhost/bookabus/";
		$(document).ready(function() {
			// Handler for .ready() called.			
			//alert($('#phone').val()+","+$('#address').val());
			if($('#phone').val()=='' || $('#address').val()=='' ){				
				$(dShadow).show();
				$(dPopup).show();				
			}else{
				$(dShadow).hide();
				$(dPopup).hide();
			}
			
			if($('#isadmin').val()!=undefined){
				$(dShadow).hide();
				$(dPopup).hide();
			}
			var userlv = <?php echo $userinfo->level;?>;
			if (userlv > 0){
				$(dShadow).hide();
				$(dPopup).hide();
			}
			$('a').click(function () {
				if ((jQuery(this).attr("title") == "Deny!") 
					|| (jQuery(this).attr("title") =='Cancel this job order')
					|| (jQuery(this).attr("title") =='Delete this job order')){
						var link = jQuery(this).attr("href");
						var sub = link.split('/');
						var id = sub[sub.length-1];
						return confirm('Are you sure you want to remove #' + id + '?');
					}				
			});				
		});	
		
		function SortJobIdUpOncomingu(){
			window.location = site_url+"sort_job_id_up_oncomingu";
		}
		function SortJobIdDownOncomingu(){
			window.location = site_url+"sort_job_id_down_oncomingu";
		}
		function SortDetailsUpOncomingu(){
			window.location = site_url+"sort_details_up_oncomingu";
		}
		function SortDetailsDownOncomingu(){
			window.location = site_url+"sort_details_down_oncomingu";
		}
		function SortJobIdUpCancelu(){
			window.location = site_url+"sort_job_id_up_cancelu";
		}
		function SortJobIdDownCancelu(){
			window.location = site_url+"sort_job_id_down_cancelu";
		}
		function SortDetailsUpCancelu(){
			window.location = site_url+"sort_details_up_cancelu";
		}
		function SortDetailsDownCancelu(){
			window.location = site_url+"sort_details_down_cancelu";
		}
		function SortJobIdUpCompleteu(){
			window.location = site_url+"sort_job_id_up_completeu";
		}
		function SortJobIdDownCompleteu(){
			window.location = site_url+"sort_job_id_down_completeu";
		}
		function SortDetailsUpCompleteu(){
			window.location = site_url+"sort_details_up_completeu";
		}
		function SortDetailsDownCompleteu(){
			window.location = site_url+"sort_details_down_completeu";
		}
		function SortJobIdUpPaymentDueu(){
			window.location = site_url+"sort_job_id_up_payment_dueu";
		}
		function SortJobIdDownPaymentDueu(){
			window.location = site_url+"sort_job_id_down_payment_due";
		}
		function SortDetailsUpPaymentDueu(){
			window.location = site_url+"sort_details_up_payment_dueu";
		}
		function SortDetailsDownPaymentDueu(){
			window.location = site_url+"sort_details_down_payment_dueu";
		}
		function SortJobIdUpDraftu(){
			window.location = site_url+"sort_job_id_up_draft";
		}
		function SortJobIdDownDraftu(){
			window.location = site_url+"sort_job_id_down_draft";
		}
		function SortDetailsUpDraftu(){
			window.location = site_url+"sort_details_up_draft";
		}
		function SortDetailsDownDraftu(){
			window.location = site_url+"sort_details_down_draft";
		}
		function runScript(e,s,n,i,num,numpages) {
		if (e.keyCode == 13) {
			if((document.getElementById('page').value < 1) || (document.getElementById('page').value > numpages)){
				alert("The number of page is not available at a moment. Please try with another number");
				document.getElementById('page').value = '';
			}
			else{
				var page = document.getElementById('page').value;
				page = page-1;
				loadJobPage(s, n, page, i ,num);
				if( n == 4){
					document.getElementById('cancel').scrollIntoView(true);
				}
				else if( n == 5){
					document.getElementById('need_quote').scrollIntoView(true);
				}
				else if( n == 6){
					document.getElementById('need_confirm').scrollIntoView(true);
				}
				else if( n == 3){
					document.getElementById('complete').scrollIntoView(true);
				}
				else if( n == 2){
					document.getElementById('payment_due').scrollIntoView(true);
				}
				else if( n == 1){
					document.getElementById('draft').scrollIntoView(true);
				}
				else if( n == 0){
					document.getElementById('oncoming').scrollIntoView(true);
				}
			}
		}
	}
	function runScript1() {
		document.getElementById('page').value = '';
	}		  
	</script>
</head>

<body>
	<?php if (isset($_SESSION) && $_SESSION['switch'] == 1): ?>
		<input type="hidden" id="isadmin" value="1" />
	<?php endif;?>
	<div id="dShadow" class="div-shadow" style="display: block; "> </div>
	<div id="dPopup" class="popup" id="dLadingPage_1">
		<h1>Profile </h1>
		<a href="http://bookabus.sg/user/logout">Logout</a>
		<div class="left">
		<?php echo form_open('/', array('class' => 'standard-form')); ?>
					<div class="one<?php if ($regErrors['name']) echo " warning"; ?>">
						<?php if ($regErrors['name']): ?><div class="warning-message">This field is mandatory.</div><?php endif; ?>
						<?php echo form_label('Full name*', 'name'); ?>
						<?php $nameInput = array('name' => 'name', 'id' => 'name'); ?>
						<?php
							$nameInput['value'] = $userinfo->name;							
						?>
						<div class="type-text"><?php echo form_input($nameInput); ?></div>
						<div class="clr"></div>
					</div>					
					<div class="one">
						<?php echo form_label('E-mail', 'email'); ?>
						<?php $emailInput = array('name' => 'email', 'id' => 'email', 'disabled' => 'disabled'); ?>
						<?php
							$emailInput['value'] = $userinfo->username;
						?>
						<div class="type-text"><?php echo form_input($emailInput); ?></div>
						<div class="clr"></div>
					</div>
					
					
                    <div class="one">
						<?php echo form_label('Company name', 'company_name'); ?>
                                            
                                            <?php 
                                            $companyName = array('name' => 'company_name', 'id' => 'company_name', 'value' => '');
                                            
                                            if(@$userinfo->company_name) {
                                                $companyName['value'] = $userinfo->company_name;
                                            }
                                            
                                            if($this->input->post('company_name')) {
                                                $companyName['value'] = $this->input->post('company_name');
                                            }
                                            ?>
                                            
						<div class="type-text"><?php echo form_input($companyName); ?></div>
						<div class="clr"></div>
					</div>
                            
					<div class="one<?php if ($regErrors['address']) echo " warning"; ?>">
						<?php if ($regErrors['address']): ?><div class="warning-message">This field is mandatory.</div><?php endif; ?>
						<?php echo form_label('Billing address*', 'address'); ?>
						<?php $addrInput = array('name' => 'address', 'id' => 'address'); ?>
						<?php
							$addrInput['value'] = $userinfo->address;
						?>
						<div class="type-textarea"><?php echo form_textarea($addrInput); ?></div>
						<div class="clr"></div>
					</div>
					<div class="one<?php if ($regErrors['phone']) echo " warning"; ?>">
						<?php if ($regErrors['phone']): ?><div class="warning-message">Please enter valid mobile phone number.</div><?php endif; ?>
						<?php echo form_label('Mobile telephone*', 'phone'); ?>
						<?php $phoneInput = array('name' => 'phone', 'id' => 'phone'); ?>
						<?php
							$phoneInput['value'] = $userinfo->phone;							
						?>
						<div class="type-text"><?php echo form_input($phoneInput); ?></div>
						<div class="clr"></div>
					</div>
					<div class="one no-left">
						<div class="type-btn"><?php echo form_submit('doregister', 'Submit'); ?></div>
						<div class="clr"></div>
					</div>
				</form>
				</div>
		<div class="right">
			Some your profile field is missing.<br/>Please fill all required field before requesting a new job !
		</div>
	</div>
	<div id="dContent">
		<?php
			if ($user->level > 0) {
				$this->load->view('header_admin.php');
			} else {
				$this->load->view('header_logged.php');
			}
		?>
				
		<!-- Content Area -->
		<div class="wrapper-world content">
			
			<div class="wrapper">
				<form class="standard-form" onsubmit="jQuery('#jobSearch').change(); return false;">
					<div class="type-text"><input type="text" id="jobSearch" value="Search job orders by ID..."/></div>
					<div class="clr"></div>
				</form>
			</div>
			
			<h1><a id="oncoming">Oncoming </a><span class="quantity"><?php echo $oncomingCount; ?></span></h1>
			<div class="job-listing">
				<div class="wrapper-world"> <!-- zaglaviq -->
					<div class="wrapper">
						<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpOncomingu();"></a></span><span class="downarrs"><a onclick="uSortJobIdDownOncomingu();"></a></span></div>
						<div class="job-details">Details <span class="uparrs"><a onclick="SortDetailsUpOncomingu();"></a></span><span class="downarrs"><a onclick="uSortDetailsDownOncomingu();"></a></span></div>
						<div class="job-status">Status</div>
						<div class="job-price">Price</div>
						<div class="job-action">Action</div>
						<div class="clr"></div>
					</div>
				</div>
				
				<div class="jobsContainer">
					<?php $c=0; foreach ($oncoming as $jobOrder):
						$job = $jobOrder['order'];
						$routes = $jobOrder['routes'];
					?>
					<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->muser == 1) { echo "  job-orange"; } ?>">
						<div class="wrapper">
							<div class="job-id"><?php echo $this->Jobs->getID($job); ?></div>
							<div class="job-details">
								<?php //if ($job->type == "2"): ?>
								
								<?php $c1 = 0; foreach ($routes as $route): ?>
									<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
									<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
								<?php endforeach; ?></div>
							<div class="job-status"><?php echo (($job->cancel == 1) ? "Cancel request" : constant("JOB_STATUS_". $job->status)); ?></div>
							<div class="job-price"><?php echo (($job->price > 0) ? $this->Jobs->formatPrice($job->price) : "&ndash;");?></div>
							<div class="job-action">
								<?php echo $this->Jobs->showActionLinks($job, "oncoming"); ?>
							</div>
							<div class="clr"></div>
						</div>
					</div>
					<?php $c++; endforeach; ?>
				</div>
				
				<div class="pagination">
					<?php
						$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
						$s = explode('/',$url);
						$k = 4;
						if($s[$k] ==""){
							$num = 0;				
						}
						else if(substr($s[$k],0,15) == "sort_job_id_up_"){
							$num =1;
						}
						else if(substr($s[$k],0,15) == "sort_job_id_dow"){
							$num =2;
						}
						else if(substr($s[$k],0,15) == "sort_details_up"){
							$num =3;
						}
						else if(substr($s[$k],0,15) == "sort_details_dow"){
							$num =4;
						}
						if( $oncomingPages > 6 ){
							for ($i = 0; $i < 3; $i++) {
								echo '<a href="#oncoming" onclick="loadJobPage(this, 0, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
							echo '<a  style="width:120px;background:none;margin-top:0px;" onclick="return runScript1();" onkeypress="return runScript(event,this,0,'.$pagingId.','.$num.','.$oncomingPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page" name="page" value="Enter page" />.....</a>';	
							for ($i = $oncomingPages-3 ; $i < $oncomingPages; $i++) {
								echo '<a href="#oncoming" onclick="loadJobPage(this, 0, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
						else{
							for ($i = 0; $i < $oncomingPages; $i++) {
								echo '<a href="#oncoming" onclick="loadJobPage(this, 0, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
					?>
					<div class="clr"></div>
				</div>
			</div>
			
			<!--          -----------------------------------------------------------------------------          -->
			
			<h1><a id="draft">Drafts</a> <span class="quantity"><?php echo $draftsCount; ?></span></h1>
			<div class="job-listing">
				<div class="wrapper-world"> <!-- zaglaviq -->
					<div class="wrapper">
						<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpDraftu();"></a></span><span class="downarrs"><a onclick="SortJobIdDownDraftu();"></a></span></div>
						<div class="job-details">Details <span class="uparrs"><a onclick="SortDetailsUpDraftu();"></a></span><span class="downarrs"><a onclick="SortDetailsDownDraftu();"></a></span></div>
						<div class="job-status">Status</div>
						<div class="job-price">Price</div>
						<div class="job-action">Action</div>
						<div class="clr"></div>
					</div>
				</div>
				
				<div class="jobsContainer">
					<?php $c=0; foreach ($drafts as $jobOrder):
						$job = $jobOrder['order'];
						$routes = $jobOrder['routes'];
					?>
					<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->muser == 1) { echo "  job-orange"; } ?>">
						<div class="wrapper">
							<div class="job-id"><?php echo $this->Jobs->getID($job); ?></div>
							<div class="job-details">
								<?php $c1 = 0; foreach ($routes as $route): ?>
									<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
									<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
								<?php endforeach; ?></div>
							<div class="job-status">Draft</div>
							<div class="job-price">&ndash;</div>
							<div class="job-action"><?php echo $this->Jobs->showActionLinks($job, "drafts"); ?></div>
							<div class="clr"></div>
						</div>
					</div>
					<?php $c++; endforeach; ?>
				</div>
				
				<div class="pagination">
					<?php
					$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
					$s = explode('/',$url);
					$k = 4;
					if($s[$k] ==""){
						$num = 0;				
					}
					else if(substr($s[$k],0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($s[$k],0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($s[$k],0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($s[$k],0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $draftsPages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#draft" onclick="loadJobPage(this, 1, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a  style="width:120px;background:none;margin-top:0px;" onclick="return runScript1();" onkeypress="return runScript(event,this,1,'.$pagingId.','.$num.','.$draftsPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page" name="page" value="Enter page" />.....</a>';	
						for ($i = $draftsPages-3 ; $i < $draftsPages; $i++) {
							echo '<a href="#draft" onclick="loadJobPage(this, 1, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $draftsPages; $i++) {
							echo '<a href="#draft" onclick="loadJobPage(this, 1, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
					<div class="clr"></div>
				</div>
			</div>
			
			<!--          -----------------------------------------------------------------------------          -->
			
			<h1><a id="payment_due">Payment Due</a> <span class="quantity"><?php echo $dueCount; ?></span> <strong>Payment Overdue</strong> <span class="quantity red"><?php echo $overdueCount; ?> &ndash; <?php echo $this->Jobs->formatPrice($overduetotal); ?></span></h1>
			<div class="job-listing">
				<div class="wrapper-world"> <!-- zaglaviq -->
					<div class="wrapper">
						<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpPaymentDueu();"></a></span><span class="downarrs"><a onclick="SortJobIdDownPaymentDueu();"></a></span></div>
						<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpPaymentDueu();"></a></span><span class="downarrs"><a onclick="SortDetailsDownPaymentDueu();"></a></span></div>
						<div class="job-date">Due date</div>
						<div class="job-price">Total</div>
						<div class="job-paid">Paid</div>
						<div class="job-left">Left to pay</div>
						<div class="job-action">Action</div>
						<div class="clr"></div>
					</div>
				</div>
				
				<div class="jobsContainer">
					<?php $c=0; foreach ($overdue as $jobOrder):
						$job = $jobOrder['order'];
						$routes = $jobOrder['routes'];
					?>
					<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->muser == 1) { echo "  job-orange"; } else { echo " job-red"; } ?>">
						<div class="wrapper">
							<div class="job-id"><?php echo $this->Jobs->getID($job); ?></div>
							<div class="job-details">
								<?php $c1 = 0; foreach ($routes as $route): ?>
									<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
									<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
								<?php endforeach; ?></div>
							<div class="job-date"><?php echo date('d M Y', strtotime($job->duedate)); ?></div>
							<div class="job-price"><?php echo $this->Jobs->formatPrice($job->price); ?></div>
							<div class="job-paid"><?php echo $this->Jobs->formatPrice($job->paid); ?></div>
							<div class="job-left"><?php echo $this->Jobs->formatPrice($job->price-$job->paid); ?></div>
							<div class="job-action"><?php echo $this->Jobs->showActionLinks($job, "overdue"); ?></div>
							<div class="clr"></div>
						</div>
					</div>
					<?php $c++; endforeach; ?>
					<?php $c=0; foreach ($due as $jobOrder):
						$job = $jobOrder['order'];
						$routes = $jobOrder['routes'];
					?>
					<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->muser == 1) { echo "  job-orange"; } ?>">
						<div class="wrapper">
							<div class="job-id"><?php echo $this->Jobs->getID($job); ?></div>
							<div class="job-details">
								<?php $c1 = 0; foreach ($routes as $route): ?>
									<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
									<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
								<?php endforeach; ?></div>
							<div class="job-date"><?php echo date('d M Y', strtotime($job->duedate)); ?></div>
							<div class="job-price"><?php echo $this->Jobs->formatPrice($job->price); ?></div>
							<div class="job-paid"><?php echo $this->Jobs->formatPrice($job->paid); ?></div>
							<div class="job-left"><?php echo $this->Jobs->formatPrice($job->price-$job->paid); ?></div>
							<div class="job-action"><?php echo $this->Jobs->showActionLinks($job, "due"); ?></div>
							<div class="clr"></div>
						</div>
					</div>
					<?php $c++; endforeach; ?>
				</div>
				
				<div class="pagination">
					<?php
						$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
						$s = explode('/',$url);
						$k = 4;
						if($s[$k] ==""){
							$num = 0;				
						}
						else if(substr($s[$k],0,15) == "sort_job_id_up_"){
							$num =1;
						}
						else if(substr($s[$k],0,15) == "sort_job_id_dow"){
							$num =2;
						}
						else if(substr($s[$k],0,15) == "sort_details_up"){
							$num =3;
						}
						else if(substr($s[$k],0,15) == "sort_details_dow"){
							$num =4;
						}
						if( $dueOverduePages > 6 ){
							for ($i = 0; $i < 3; $i++) {
								echo '<a href="#payment_due" onclick="loadJobPage(this, 2, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
							echo '<a  style="width:120px;background:none;margin-top:0px;" onclick="return runScript1();" onkeypress="return runScript(event,this,2,'.$pagingId.','.$num.','.$dueOverduePages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page" name="page" value="Enter page" />.....</a>';	
							for ($i = $dueOverduePages-3 ; $i < $dueOverduePages; $i++) {
								echo '<a href="#payment_due" onclick="loadJobPage(this, 2, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
						else{
							for ($i = 0; $i < $dueOverduePages; $i++) {
								echo '<a href="#payment_due" onclick="loadJobPage(this, 2, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
					?>
					<div class="clr"></div>
				</div>
			</div>
			
			<!--          -----------------------------------------------------------------------------          -->
			
			<h1><a id="complete">Completed</a> <span class="quantity"><?php echo $completedCount; ?></span></h1>
			<div class="job-listing">
				<div class="wrapper-world"> <!-- zaglaviq -->
					<div class="wrapper">
						<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpCompleteu();"></a></span><span class="downarrs"><a onclick="SortJobIdDownCompleteu();"></a></span></div>
						<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpCompleteu();"></a></span><span class="downarrs"><a onclick="SortDetailsDownCompleteu();"></a></span></div>
						<div class="job-date">Completed</div>
						<div class="job-price">Price</div>
						<div class="job-action">Action</div>
						<div class="clr"></div>
					</div>
				</div>
				
				<div class="jobsContainer">
					<?php $c=0; foreach ($completed as $jobOrder):
						$job = $jobOrder['order'];
						$routes = $jobOrder['routes'];
					?>
					<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); ?>">
						<div class="wrapper">
							<div class="job-id"><?php echo $this->Jobs->getID($job); ?></div>
							<div class="job-details">
								<?php $c1 = 0; foreach ($routes as $route): ?>
									<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
									<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
								<?php endforeach; ?>
							</div>
							<div class="job-date"><?php echo $job->date; ?></div>
							<div class="job-price"><?php echo (($job->price > 0) ? $this->Jobs->formatPrice($job->price) : "&ndash;");?></div>
							<div class="job-action"><?php echo $this->Jobs->showActionLinks($job, "completed"); ?></div>
							<div class="clr"></div>
						</div>
					</div>
					<?php $c++; endforeach; ?>
				</div>
				
				<div class="pagination">
					<?php
						$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
						$s = explode('/',$url);
						$k = 4;
						if($s[$k] ==""){
							$num = 0;				
						}
						else if(substr($s[$k],0,15) == "sort_job_id_up_"){
							$num =1;
						}
						else if(substr($s[$k],0,15) == "sort_job_id_dow"){
							$num =2;
						}
						else if(substr($s[$k],0,15) == "sort_details_up"){
							$num =3;
						}
						else if(substr($s[$k],0,15) == "sort_details_dow"){
							$num =4;
						}
						if( $completedPages > 6 ){
							for ($i = 0; $i < 3; $i++) {
								echo '<a href="#complete" onclick="loadJobPage(this, 3, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
							echo '<a  style="width:120px;background:none;margin-top:0px;" onclick="return runScript1();" onkeypress="return runScript(event,this,3,'.$pagingId.','.$num.','.$completedPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page" name="page" value="Enter page" />.....</a>';	
							for ($i = $completedPages-3 ; $i < $completedPages; $i++) {
								echo '<a href="#complete" onclick="loadJobPage(this, 3, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
						else{
							for ($i = 0; $i < $completedPages; $i++) {
								echo '<a href="#complete" onclick="loadJobPage(this, 3, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
					?>
					<div class="clr"></div>
				</div>
			</div>
			
			<!--          -----------------------------------------------------------------------------          -->
			
			<h1><a id="cancel">Cancelled </a> <span class="quantity"><?php echo $cancelledCount; ?></span></h1>
			<div class="job-listing">
				<div class="wrapper-world"> <!-- zaglaviq -->
					<div class="wrapper">
						<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpCancelu();"></a></span><span class="downarrs"><a onclick="SortJobIdDownCancelu();"></a></span></div>
						<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpCancelu();"></a></span><span class="downarrs"><a onclick="SortDetailsDownCancelu();"></a></span></div>
						<div class="job-status">Status</div>
						<div class="job-price">Price</div>
						<div class="job-action">Action</div>
						<div class="clr"></div>
					</div>
				</div>
				
				<div class="jobsContainer">
					<?php $c=0; foreach ($cancelled as $jobOrder):
						$job = $jobOrder['order'];
						$routes = $jobOrder['routes'];
					?>
					<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); ?>">
						<div class="wrapper">
							<div class="job-id"><?php echo $this->Jobs->getID($job); ?></div>
							<div class="job-details">
								<?php $c1 = 0; foreach ($routes as $route): ?>
									<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
									<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
								<?php endforeach; ?>
							</div>
							<div class="job-status"><?php echo constant("JOB_STATUS_". $job->status); ?></div>
							<div class="job-price"><?php echo (($job->price > 0) ? $this->Jobs->formatPrice($job->price) : "&ndash;");?></div>
							<div class="job-action"><?php echo $this->Jobs->showActionLinks($job, "cancelled"); ?></div>
							<div class="clr"></div>
						</div>
					</div>
					<?php $c++; endforeach; ?>
				</div>
				
				<div class="pagination">
					<?php
						$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
						$s = explode('/',$url);
						$k = 4;
						if($s[$k] ==""){
							$num = 0;				
						}
						else if(substr($s[$k],0,15) == "sort_job_id_up_"){
							$num =1;
						}
						else if(substr($s[$k],0,15) == "sort_job_id_dow"){
							$num =2;
						}
						else if(substr($s[$k],0,15) == "sort_details_up"){
							$num =3;
						}
						else if(substr($s[$k],0,15) == "sort_details_dow"){
							$num =4;
						}
						if( $cancelledPages > 6 ){
							for ($i = 0; $i < 3; $i++) {
								echo '<a href="#cancel" onclick="loadJobPage(this, 4, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
							echo '<a style="width:120px;background:none;margin-top:0px;" onclick="return runScript1();" onkeypress="runScript(event,this,4,'.$pagingId.','.$num.','.$cancelledPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page" name="page" value="Enter page" />.....</a>';	
							for ($i = $cancelledPages-3 ; $i < $cancelledPages; $i++) {
								echo '<a href="#cancel" onclick="loadJobPage(this, 4, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
						else{
							for ($i = 0; $i < $cancelledPages; $i++) {
								echo '<a href="#cancel" onclick="loadJobPage(this, 4, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
							}
						}
					?>
					<div class="clr"></div>
				</div>
			</div>
		</div> <!-- end of wrapper-world and .content -->
		
		
			
		<div class="wrapper-world footer-top">
			<div class="wrapper"></div>	
		</div>
		
		<?php $this->load->view('footer'); ?>
	</div>
</body>
</html>
